package factory.one.utils;

import factory.one.entity.Order;
import factory.one.pojo.StageVO;

public class StageUtil {

    public static void build(Order order) {
        StageVO[] stages = new StageVO[3];
        Boolean confirm = order.getConfirm();
        int orderNum = order.getOrderNum();
        int produceNum = order.getProduceNum();
        int sendNum = order.getSendNum();
        if (confirm) {
            stages[0] = StageVO.done();
            if (produceNum == 0) {
                stages[1] = StageVO.ready();
            } else if (produceNum >= orderNum) {
                stages[1] = StageVO.done();
            } else {
                stages[1] = StageVO.start();
            }
            if (sendNum == 0) {
                if (produceNum == 0) {
                    stages[2] = StageVO.notStart();
                } else {
                    stages[2] = StageVO.ready();
                }
            } else if (sendNum >= orderNum) {
                stages[2] = StageVO.done();
            } else {
                stages[2] = StageVO.start();
            }
        } else {
            stages[0] = StageVO.start();
            stages[1] = StageVO.notStart();
            stages[2] = StageVO.notStart();
        }
        order.setStages(stages);
    }

}
